package org.lemon.transport.context.service;

import org.lemon.transport.context.data.tenant.TenantId;
import org.lemon.transport.context.data.tenant.TenantProfile;
import org.lemon.transport.context.service.queue.discovery.TenantRoutingInfo;
import org.lemon.transport.context.service.queue.discovery.TenantRoutingInfoService;
import org.springframework.stereotype.Service;

@Service
public class TransportTenantRoutingInfoService implements TenantRoutingInfoService {

    private TransportTenantProfileCache tenantProfileCache;

    public TransportTenantRoutingInfoService(TransportTenantProfileCache tenantProfileCache) {
        this.tenantProfileCache = tenantProfileCache;
    }

    @Override
    public TenantRoutingInfo getRoutingInfo(TenantId tenantId) {
        TenantProfile profile = tenantProfileCache.get(tenantId);
        return new TenantRoutingInfo(tenantId, profile.isIsolatedTbRuleEngine());
    }
}
